<?php

namespace app\admin\model;

use think\Model;

class Tag_correlation extends Model
{

    public function add($arcid,$tagid=[])
    {
        $list = [];
        if (is_array($tagid)){
            foreach ($tagid as $val){
                $list[] = ['arcid'=>$arcid ,'tagid'=>$val];
            }
            $this->saveAll($list);
            return 1;
        }
        return 0;
    }


    public static function allTagid($arcid)
    {
        $where = function ($query) use ($arcid){
            $query->field(['tagid'])->where(['arcid'=>$arcid]);
        };
        $arr = parent::all($where);
        $tagid = [];
        foreach ($arr as $val){
            $tagid[] = $val->getData()['tagid'];
        }
        return $tagid;
    }
}
